//
//  DBSteps.m
//  CareRingApp
//
//  Created by Linktop on 2022/7/4.
//

#import "DBSteps.h"
#import "DBHistoryDataSr03.h"
//NSString * const TABLE_NM_STEPS = @"table_steps";

@implementation DBSteps


+(void)queryBy:(NSString * _Nonnull)macAddress
         Begin:(NSDate *)beginDate End:(NSDate *)endDate
OrderBeTimeDesc:(BOOL)isDesc
      Cpmplete:(void(^)(NSMutableArray<DBSteps *> *results))cmpBlk
{
    
    [DBHistoryDataSr03 queryBy:macAddress Begin:beginDate End:endDate OrderBeTimeDesc:isDesc Cpmplete:^(NSMutableArray<DBHistoryDataSr03 *> * _Nonnull results) {
        
        NSMutableArray<DBSteps *> *stepRes = [NSMutableArray new];
        for (DBHistoryDataSr03 *hisObj in results) {
            
            if (hisObj.steps) {
                DBSteps *stepModel = [[DBSteps alloc]init];
                
//                if (!hisObj.devFixStep) {
//                    stepModel.value = @((int)(hisObj.steps.floatValue * 2/3.0f));// 2023-7-11 添加修正 2/3
//                } else {
                stepModel.value = hisObj.steps;
//                }
                stepModel.motion = hisObj.soprtTimes;
                stepModel.time = [NSDate dateWithTimeIntervalSince1970:hisObj.time.doubleValue];
                stepModel.macAddress = hisObj.macAddress;
                stepModel.battery = hisObj.battery;
                [stepRes addObject:stepModel];
            }
           
        }
        
        if (cmpBlk) {
            dispatch_async(dispatch_get_main_queue(), ^{
                cmpBlk(stepRes);
            });
        }
        
    }];
    

}




@end
